<template>
	<view>
		<u-empty v-if="invoicesList == ''"   iconColor="#f18b49" text="暂无开票信息,点击下方按钮添加" style="margin-top: 150rpx;"></u-empty>
		<view v-else  v-for="(item,index) in invoicesList" :key="index">
			<view  class="head-invoice">
				<view class="invoices-box">
					<text class="adres-txt-1">默认</text>
					<text class="adres-txt-3">{{ item.company_name }}</text>
					<view class="adres-txt-2">纳税人识别码：{{ item.taxcode }}</view>
					<text class="adres-txt-4">地址:{{ item.address }}</text>
					<text class="adres-txt-5">{{ item.mobile }}</text>
				</view>
				<uni-icons type="compose" size="24" @click="editInvoice(item.id)"></uni-icons>
			</view>
			<u-divider hairline dashed style="margin: 0;"></u-divider>
		</view>
		<view class="bot-btn">
			<view class="btn-box" @click="addInvoiceInfo()">
				<uni-icons type="plusempty" color="#FFFFFF" style="margin-top: 4rpx;"></uni-icons>
				<text>添加开票信息</text>
			</view>
		</view>
	</view>
</template>

<script>
	// company_name:单位名称 taxcode:纳税人识别码 address:注册地址
	// telphone:注册电话 bankname:开户银行 bankno:银行账户 type:1代表普通发票2代表增值税专用发票
	export default {
		data() {
			return {
				user_id:'',
				invoicesList:[],
				
			}
		},
		onLoad(e){
			this.user_id = e.user_id //用户id
			this.getInvoice( )
		},
		onShow(e){
	
			 this.getInvoice()
		},
		methods: {
			//获取开票信息
			getInvoice(){
					this.$getHttp(`/gjcApi/invoice_list?user_id=`+this.user_id,{},res=>{
						 if(res.code == 200){
							 this.invoicesList = res.data;
							 //console.log(this.invoicesList)
						 }else{
							 uni.showToast({
							 	tit:rew.msg,
								duration:1500,
								icon:'error'
							 })
						 }
					})
			},
			// 添加发票
			addInvoiceInfo(){
				uni.navigateTo({
					url: '/pages/invoice/add-invoice?userId=' + this.user_id
				})
			},
			//删除发票
			delInvoiceInfo(){
				this.$getHttp(`/gjcApiinvoice_del?user_id=${this.user_id}`,{},res=>{
					if(res.code == 200){
						uni.showToast({
							tit:res.msg,
							duration:1500,
							icon:'success'
						})
					}else{
						uni.showToast({
							tit:res.msg,
							duration:1500,
							icon:'error'
						})
					}
				})
			},
			//编辑发票
			editInvoice(id){
				uni.navigateTo({
					url:'/pages/invoice/edit-invoice?id='+id+'&user_id='+this.user_id
				})
			}
		}
	}
</script>

<style  lang="scss" scoped>
	page{
		background: $uni-model-color;
	}
.head-invoice{
	display: flex;
	align-items: center;
	padding: 20rpx 35rpx;
	justify-content: space-between;
	.invoices-box{
		.adres-txt-1{
			color: #FFFFFF;
			padding: 0 8rpx;
			font-size: 26rpx;
			border-radius: 6rpx;
			margin-right: 15rpx;
			background: $uni-text-color;
		}
		.adres-txt-2{
			font-size: 28rpx;
			letter-spacing: 2rpx;
			color: $uni-text-color-placeholder;
		}
		.adres-txt-3{
			margin: 10rpx 0;
			font-size: 34rpx;
			font-weight: bold;
			letter-spacing: 1rpx;
		}
		.adres-txt-4,.adres-txt-5{
			font-size: 28rpx;
			margin-right: 20rpx;
			color: $uni-text-color-placeholder;
		}
	}
}
.bot-btn{
	bottom: 0;
	width: 750rpx;
	position: fixed;
	text-align: center;
	margin-bottom: 30rpx;
	padding: 20rpx 150rpx;
	.btn-box{
		display: flex;
		width: 450rpx;
		color: #FFFFFF;
		padding: 22rpx 0;
		font-size: 30rpx;
		align-items: center;
		background: #ff914d;
		letter-spacing: 2rpx;
		border-radius: 50rpx;
		justify-content: center;
		text{
			margin-left: 4rpx;
		}
	}
}
</style>
